package com.leyou.item.mapper;

import com.leyou.item.interfaces.pojo.Brand;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * Brand的表对应的持久层
 * @version 1.0.0
 * @Author yong.Mr
 * @data 2019-8-9
 */
public interface BrandMapper extends Mapper<Brand> {

    // 使用SQL语句实现分页查询
    @SelectProvider(type = BrandMapperProvider.class,method = "getSqlQueryBrandByPage")
    public List<Brand> queryBrandByPageSqls(String key, Integer page, Integer rows,
                                            String sortBy, Boolean desc,Boolean flag);

    // 查询该商品分类下的品牌
    @Select("SELECT * FROM tb_brand b INNER JOIN tb_category_brand cb ON cb.brand_id = b.id WHERE cb.category_id = #{cid}")
    List<Brand> queryBrandByCid(@Param("cid") Long cid);



}
